#!/usr/bin/env python
#coding=utf-8

import db, utils
from ex import NoPrice
d529 = utils.get_date_isostr(2007,5,29)
d629 = utils.get_date_isostr(2007,6,29) 

scoder = utils.get_scoder()
con = utils.get_db_connector()

while True:
    try:
        code = unicode(scoder.next()[0])
        #print code
    except KeyError:
        break    
    
    try:
        close529 = db.lookup_price(con.cursor(), code, d529)['close']
        close629 = db.lookup_price(con.cursor(), code, d629)['close']
    except NoPrice:
        continue
    
    range =  (close529 - close629)/close529
    if range > 0.5:print range, code